package Day1;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

public class SetTest {
    public static void main(String[] args) {
        Set<String>set=new HashSet<>();
        set.add("dog");
        set.add("cat");
        set.add("mouse");
        String[]object=set.toArray(new String[0]);
        System.out.println(object.length);
        System.out.println("第一种");
        System.out.println(Arrays.toString(object));
        System.out.println("第二种");
        for (String s:set){
            System.out.println(s);
        }
        System.out.println("第三种");
        Iterator<String> ir=set.iterator();
        while (ir.hasNext()){//还有没有下一个
            String next=ir.next();
            System.out.println(next);
        }
    }
}
